#include "pubmedgenomeelementdatapacket.h"

//-------------------------------CONSTRUCTORS ------------------------------------------
PubMedGenomeElementDataPacket::PubMedGenomeElementDataPacket(QObject *parent) :
    GenomeElementDataPacket(parent)
{

}

PubMedGenomeElementDataPacket::PubMedGenomeElementDataPacket( QString seqId, QString source, QString type, int start, int stop, bool posStrand,
                                                              QString parentContigId, bool hasCluster, QString clusterId,
                                                              bool hasSpecies, QString species,
                                                              QString id, QString name, QString product, QString parentElement,
                                                              QObject *parent)
                                                            :
                                                              GenomeElementDataPacket( seqId, source, type, start, stop, posStrand,
                                                                                        parentContigId, hasCluster, clusterId,
                                                                                        hasSpecies, species, parent ),
                                                              id(id), name(name), product(product), parentElement( parentElement)
{


}


//-------------------------------SETTERS ------------------------------------------
void PubMedGenomeElementDataPacket::setAll( QString seqId, QString source, QString type, int start, int stop, bool posStrand,
                                            QString parentContigId, bool hasCluster, QString clusterId,
                                            bool hasSpecies, QString species,
                                            QString id, QString name, QString product, QString parentElement )
{
    setSeqId( seqId );
    setSource( source );
    setType( type );
    setStart( start );
    setStop( stop );
    setPosStrand( posStrand );
    setParentContigId( parentContigId );
    setHasCluster( hasCluster );
    setClusterId( clusterId );
    setHasSpecies( hasSpecies );
    setSpecies( species );
    setId( id );
    setName( name );
    setProduct( product );
    setParentElement( parentElement );
}

void PubMedGenomeElementDataPacket::setId( QString id )
{
    this->id = id;
}

void PubMedGenomeElementDataPacket::setName( QString name )
{
    this->name = name;
}

void PubMedGenomeElementDataPacket::setProduct( QString product )
{
    this->product = product;
}

void PubMedGenomeElementDataPacket::setParentElement( QString parentElement )
{
    this->parentElement = parentElement;
}


//-------------------------------GETTERS ------------------------------------------


QString PubMedGenomeElementDataPacket::getId( )
{
    return id;
}

QString PubMedGenomeElementDataPacket::getName( )
{
    return name;
}

QString PubMedGenomeElementDataPacket::getProduct( )
{
    return product;
}

QString PubMedGenomeElementDataPacket::getParentElement( )
{
    return parentElement;
}

QString PubMedGenomeElementDataPacket::getIdentifierToDisplay()
{
    if( product.compare("-") != 0 && !product.size() == 0)
        return product;
    else if( name.compare("-") != 0 )
        return name;
    else if( id.compare("-") != 0 )
        return id;
    else
        return getSeqId();
}

QString PubMedGenomeElementDataPacket::getDataToDisplay()
{
    QString toReturn = "";//getIdentifierToDisplay();
    if( product.compare("-") != 0 && !product.size() == 0)
        toReturn += "Product:  " + product + "\n";
    else if( name.compare("-") != 0 )
        toReturn += "Name:  " + name + "\n";
    else if( id.compare("-") != 0 )
        toReturn += "Id:  " + id + "\n";
    toReturn += super::getDataToDisplay();
    //toReturn +=  "Sequence Id: " + getSeqId();
    return toReturn;
}


//-----------------------------PRINT OUT GENOME ELEMENT-------------------------------

QString PubMedGenomeElementDataPacket::toString()
{
    return super::toString() + "\t" + getId() + "\t" + getName() + "\t" + getProduct() + "\t" + getParentElement();
}

QString PubMedGenomeElementDataPacket::getUniqueId()
{
    if( name.compare("-") != 0 )
        return name;
    else
        return seqId;
}
